function ajaxLoadArticle() {
	var dt = {
		article_id : article_id
	};
	$.ajax({
		url : rootPath + "/blog/getArticleById",
		type : "post",
		dataType : "json",
		data : dt,
		success : ajaxLoadArticle_back
	});
}

function ajaxLoadArticle_back(res) {
	if (res.result == JS_AJAX_SUCCESS) {
		ajaxLoadUserinfo(res.bad.loginname);
		ajaxAddArticleVisitCnt(res.bad.blogId);

		var htmlStr = "";
		htmlStr += "标题：" + res.bad.blogTitle + "<br />";
		htmlStr += "内容：" + res.bad.blogContent + "<br />";
		htmlStr += "作者：" + res.bad.loginname + "<br />";
		htmlStr += "发布时间：" + res.bad.blogCreateDttmStr + "<br />";
		htmlStr += "标签：" + res.bad.blogTags + "<br />";
		$('#blog-article').append(htmlStr);
	}
}
$(function() {
	ajaxLoadArticle();
	ajaxGetBlogCommentByArticleId();
});

function ajaxLoadUserinfo(loginname) {
	$.ajax({
		url : rootPath + "/user/getUserById",
		type : "post",
		dataType : "json",
		data : {
			loginname : loginname
		},
		success : ajaxLoadUserinfo_back
	});
}

function ajaxLoadUserinfo_back(res) {
	if (res.result == JS_AJAX_SUCCESS) {
		var htmlStr = "";
		htmlStr += "用户名：" + res.ud.userNickname + "<br />";
		htmlStr += "<a href='javascript: ajaxAddBlogAttention(\"" + res.ud.userLoginname + "\")'>关注</a>";
		$('#blog-user').append(htmlStr);
	}
}

function ajaxAddArticleVisitCnt(article_id) {
	var dt = {
		article_id : article_id
	};
	$.ajax({
		url : rootPath + "/blog/addBlogArticleVisitCnt",
		type : "post",
		dataType : "json",
		data : dt,
		success : ajaxAddArticleVisitCnt_back
	});
}

function ajaxAddArticleVisitCnt_back(res) {

}

function ajaxBlogComment() {
	var blog_comment_content = $('#blog-comment-content').val();
	var dt = {
		article_id : article_id,
		blog_comment_content : blog_comment_content
	};
	$.ajax({
		url : rootPath + "/blog/comment/addBlogComment",
		type : "post",
		dataType : "json",
		data : dt,
		success : ajaxBlogComment_back
	});
}

function ajaxBlogComment_back(res) {
	if (res.result == JS_AJAX_SUCCESS) {
		alert("评论成功");
		ajaxGetBlogCommentByArticleId();
	}
}

function ajaxGetBlogCommentByArticleId() {
	var dt = {
		article_id : article_id
	};
	$.ajax({
		url : rootPath + "/blog/comment/getBlogCommentByArticleId",
		type : "post",
		dataType : "json",
		data : dt,
		success : ajaxGetBlogCommentByArticleId_back
	});
}

function ajaxGetBlogCommentByArticleId_back(res) {
	if (res.result == JS_AJAX_SUCCESS) {
		var htmlStr = "";
		$.each(res.bcdList, function(i) {
			htmlStr += i + "楼 发表时间：" + this.commentCreateDttmStr + "<br />";
			htmlStr += "评论人：" + this.loginname + "<br />";
			htmlStr += "内容：" + this.commentContent + "<br />";
			htmlStr += "<br />";
		});
		$('#blog-comment').html(htmlStr);
	} else {
		alert(res.msg);
	}
}

function ajaxAddBlogAttention(loginname_to) {
	var dt = {
		loginname_to : loginname_to
	};
	$.ajax({
		url : rootPath + "/user/attention/addBlogUserAttention",
		type : "post",
		dataType : "json",
		data : dt,
		success : ajaxAddBlogAttention_back
	});
}

function ajaxAddBlogAttention_back(res) {
	if (res.result == JS_AJAX_SUCCESS) {
		alert("关注成功");
	} else {
		alert(res.msg);
	}
}